package com.fbt.energy;

import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author Shun yuan
 * @date 2022年01月17日 14:01
 */
 class test2 {
    public static void main(String[] args) {

     //   testMap2List();
        int length = "https://diseng-sparepart.oss-cn-chengdu.aliyuncs.com/2022/01/22/c6eDD505500B6478051430FF18E4908D6A2.jpg".length();
        System.out.println(length+"字符串的长度");
        /*  String[] yearFullMonth = getYearFullMonth("2022");
        System.out.println(Arrays.toString(yearFullMonth));*/
    }
    @Test
    public static void testMap2List(){
        Map<String, String> map = new HashMap<String, String>();
        map.put("1", "AA");
        map.put("2", "BB");
        map.put("3", "CC");
        map.put("4", "DD");

        Collection<String> valueCollection = map.values();
        final int size = valueCollection.size();
        List<String> valueList = new ArrayList<String>(valueCollection);
        String[] valueArray = new String[size];
        map.values().toArray(valueArray);
    }


    public static String[] getYearFullMonth(String year){


        String[] array = new String[12];
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR,Integer.parseInt(year));
        cal.set(Calendar.MONTH, 0);
        for(int i=0;i<12;i++){
            array[i] = sdf.format(cal.getTime());
            cal.add(Calendar.MONTH, 1);
        }
        return array;
    }
  @Test
  public static List<String> getDayByMonth(int yearParam,int monthParam){
      List<String> list = new ArrayList<>();
      Calendar calendar = Calendar.getInstance(Locale.CHINA);
      calendar.set(yearParam, monthParam-1, 1);
      int year = calendar.get(Calendar.YEAR);//年份
      int month = calendar.get(Calendar.MONTH) + 1;//月份
      int day = calendar.getActualMaximum(Calendar.DATE);
      for (int i = 1; i <= day; i++) {
          String date=null;
          if(month<10 && i<10){
              date = String.valueOf(year)+"-0"+month+"-0"+i;
          }
          if(month<10 && i>=10){
              date = String.valueOf(year)+"-0"+month+"-"+i;
          }
          if(month>=10 && i<10){
              date = String.valueOf(year)+"-"+month+"-0"+i;
          }
          if(month>=10 && i>=10){
              date = String.valueOf(year)+"-"+month+"-"+i;
          }

          list.add(date);
      }
      return list;
  }
}
